package cn.jbit.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jbit.news.dao.impl.NewsDaoImpl;

@SuppressWarnings("serial")
public class deleteService extends HttpServlet{

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		resp.setContentType("text/html;charset=UTF-8");
		int nid=Integer.valueOf(req.getParameter("id"));
		NewsDaoImpl nd=new NewsDaoImpl();
		int result=nd.del(nid);
		PrintWriter out=resp.getWriter();
		if(result>0){
    		resp.sendRedirect("newspages/admin.jsp");
    	}else{
    		out.println("删除失败");
    		out.close();
    	}
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		super.destroy();
	}

	@Override
	public void init() throws ServletException {
		// TODO Auto-generated method stub
		super.init();
	}

}
